#include <iostream>
using namespace std;

int GetMonthDay(int& year, int& month)
{
    int Day[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
    if (month == 2 && (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)))
    {
        return 29;
    }
    return Day[month];
}

int main()
{
    int y = 0, n = 0;


    while (scanf("%d %d", &y, &n) != EOF)
    {
        int m = 1;
        if (n > 31)
        {
            while (n > GetMonthDay(y, m))
            {
                n -= GetMonthDay(y, m);
                m++;
                if (m == 13)
                {
                    y++;
                    m = 1;
                }
            }
        }
        printf("%04d-%02d-%02d\n", y, m, n);
    }
    return 0;
}